<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>
fetch('http://localhost:3000/user?id=666')
.then(res => {
    return res.json() //json/text/formData
}).then(res => {
    console.log(res);
})

fetch('http://localhost:3000/user',{
    method:'post',
    headers:{
        'Content-Type':'application/json'
    },
    body:JSON.stringify({id:166,name:'xiazi'})
}).then(res => {
    return res.json() //json/text/formData
}).then(res => {
    console.log(res);
})




//第二个参数为配置对象如method

//与ajax的区别：
//1）fetch请求默认不会发送cookie
//2）不会拒绝http的错误状态，即使响应的是404或500
</script>
</body>
</html>